package be.kuleuven.peno3.mobiletoledo.view.messages;

import java.util.Calendar;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import be.kuleuven.peno3.mobiletoledo.R;
import be.kuleuven.peno3.mobiletoledo.Data.Client.MessagesClient;
import be.kuleuven.peno3.mobiletoledo.model.Message;

public class Show extends Activity {
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.showmessage);
		
		TextView title = (TextView) findViewById(R.id.title);
		TextView author = (TextView) findViewById(R.id.author);
		TextView date = (TextView) findViewById(R.id.date);
		TextView text = (TextView) findViewById(R.id.text);
		
		int messageId = this.getIntent().getExtras().getInt("messageId");
		
		Message message=MessagesClient.getMessage(messageId);
		
		Calendar cal = message.getCal();
		title.setText(message.getTitle());
		String auteur = message.getAuthor();
		if (auteur.equals("null")){
			auteur = "Onbekende persoon";
		}
		author.setText(auteur);
		date.setText(translateDay(cal.get(Calendar.DAY_OF_WEEK)) + " " + cal.get(Calendar.DAY_OF_MONTH)+"/"+(cal.get(Calendar.MONTH)+1)+"/"+cal.get(Calendar.YEAR)+", "+cal.get(Calendar.HOUR_OF_DAY)+"u"+cal.get(Calendar.MINUTE));
		text.setText(message.getBody());
//		v.setText("Auteur: "+message.getAuthor()+"\n"
//				+"Titel: "+message.getTitle()+"\n"
//				+"Op "+cal.get(Calendar.DAY_OF_MONTH)+"/"+(cal.get(Calendar.MONTH)+1)+"/"+cal.get(Calendar.YEAR)+" om "+cal.get(Calendar.HOUR_OF_DAY)+"u"+cal.get(Calendar.MINUTE)+"\n"
//				+"Bericht:" +message.getBody()+"\n");
	}
	
	private String translateDay(int day){
		String[] days = new String [] {"", "Zo", "Ma", "Di", "Wo", "Do", "Vr", "Za"};
		return days[day];
	}
}
